home *** CD-ROM | disk | FTP | other *** search
/ IRIX Base Documentation 2001 May / SGI IRIX Base Documentation 2001 May.iso / usr / share / catman / p_man / cat3 / c++ / manip.z / manip
Encoding:
Text File  |  1998-10-30  |  16.1 KB  |  199 lines

  1.  
  2.  
  3.  
  4. MMMMAAAANNNNIIIIPPPP((((3333CCCC++++++++))))                                                        MMMMAAAANNNNIIIIPPPP((((3333CCCC++++++++))))
  5.  
  6.  
  7.  
  8. NNNNAAAAMMMMEEEE
  9.      manipulators - iostream out of band manipulations
  10.  
  11. SSSSYYYYNNNNOOOOPPPPSSSSIIIISSSS
  12.      ####iiiinnnncccclllluuuuddddeeee <<<<iiiioooossssttttrrrreeeeaaaammmm....hhhh>>>>
  13.      ####iiiinnnncccclllluuuuddddeeee <<<<iiiioooommmmaaaannnniiiipppp....hhhh>>>>
  14.  
  15.      IIIIOOOOMMMMAAAANNNNIIIIPPPPddddeeeeccccllllaaaarrrreeee((((TTTT)))) ;;;;
  16.  
  17.      ccccllllaaaassssssss SSSSMMMMAAAANNNNIIIIPPPP((((TTTT)))) {{{{
  18.                SSSSMMMMAAAANNNNIIIIPPPP((((TTTT))))(((( iiiioooossss&&&& ((((****))))((((iiiioooossss&&&&,,,,TTTT)))),,,, TTTT))));;;;
  19.                ffffrrrriiiieeeennnndddd    iiiissssttttrrrreeeeaaaammmm&&&& ooooppppeeeerrrraaaattttoooorrrr>>>>>>>>((((iiiissssttttrrrreeeeaaaammmm&&&&,,,, SSSSMMMMAAAANNNNIIIIPPPP((((TTTT))))&&&&))));;;;
  20.                ffffrrrriiiieeeennnndddd    oooossssttttrrrreeeeaaaammmm&&&& ooooppppeeeerrrraaaattttoooorrrr<<<<<<<<((((oooossssttttrrrreeeeaaaammmm&&&&,,,, SSSSMMMMAAAANNNNIIIIPPPP((((TTTT))))&&&&))));;;;
  21.      }}}};;;;
  22.      ccccllllaaaassssssss SSSSAAAAPPPPPPPP((((TTTT)))) {{{{
  23.                SSSSAAAAPPPPPPPP((((TTTT))))(((( iiiioooossss&&&& ((((****))))((((iiiioooossss&&&&,,,,TTTT))))))));;;;
  24.                SSSSMMMMAAAANNNNIIIIPPPP((((TTTT)))) ooooppppeeeerrrraaaattttoooorrrr(((())))((((TTTT))));;;;
  25.      }}}};;;;
  26.      ccccllllaaaassssssss IIIIMMMMAAAANNNNIIIIPPPP((((TTTT)))) {{{{
  27.                IIIIMMMMAAAANNNNIIIIPPPP((((TTTT))))(((( iiiissssttttrrrreeeeaaaammmm&&&& ((((****))))((((iiiissssttttrrrreeeeaaaammmm&&&&,,,,TTTT)))),,,, TTTT))));;;;
  28.                ffffrrrriiiieeeennnndddd    iiiissssttttrrrreeeeaaaammmm&&&& ooooppppeeeerrrraaaattttoooorrrr>>>>>>>>((((iiiissssttttrrrreeeeaaaammmm&&&&,,,, IIIIMMMMAAAANNNNIIIIPPPP((((TTTT))))&&&&))));;;;
  29.      }}}};;;;
  30.      ccccllllaaaassssssss IIIIAAAAPPPPPPPP((((TTTT)))) {{{{
  31.                IIIIAAAAPPPPPPPP((((TTTT))))(((( iiiissssttttrrrreeeeaaaammmm&&&& ((((****))))((((iiiissssttttrrrreeeeaaaammmm&&&&,,,,TTTT))))))));;;;
  32.                IIIIMMMMAAAANNNNIIIIPPPP((((TTTT)))) ooooppppeeeerrrraaaattttoooorrrr(((())))((((TTTT))));;;;
  33.      }}}};;;;
  34.      ccccllllaaaassssssss OOOOMMMMAAAANNNNIIIIPPPP((((TTTT)))) {{{{
  35.                OOOOMMMMAAAANNNNIIIIPPPP((((TTTT))))(((( oooossssttttrrrreeeeaaaammmm&&&& ((((****))))((((oooossssttttrrrreeeeaaaammmm&&&&,,,,TTTT)))),,,, TTTT))));;;;
  36.                ffffrrrriiiieeeennnndddd    oooossssttttrrrreeeeaaaammmm&&&& ooooppppeeeerrrraaaattttoooorrrr<<<<<<<<((((oooossssttttrrrreeeeaaaammmm&&&&,,,, OOOOMMMMAAAANNNNIIIIPPPP((((TTTT))))&&&&))));;;;
  37.      }}}};;;;
  38.      ccccllllaaaassssssss OOOOAAAAPPPPPPPP((((TTTT)))) {{{{
  39.                OOOOAAAAPPPPPPPP((((TTTT))))(((( oooossssttttrrrreeeeaaaammmm&&&& ((((****))))((((oooossssttttrrrreeeeaaaammmm&&&&,,,,TTTT))))))));;;;
  40.                OOOOMMMMAAAANNNNIIIIPPPP((((TTTT)))) ooooppppeeeerrrraaaattttoooorrrr(((())))((((TTTT))));;;;
  41.      }}}};;;;
  42.      ccccllllaaaassssssss IIIIOOOOMMMMAAAANNNNIIIIPPPP((((TTTT)))) {{{{
  43.                IIIIOOOOMMMMAAAANNNNIIIIPPPP((((TTTT))))(((( iiiioooossssttttrrrreeeeaaaammmm&&&& ((((****))))((((iiiioooossssttttrrrreeeeaaaammmm&&&&,,,,TTTT)))),,,, TTTT))));;;;
  44.                ffffrrrriiiieeeennnndddd    iiiissssttttrrrreeeeaaaammmm&&&& ooooppppeeeerrrraaaattttoooorrrr>>>>>>>>((((iiiioooossssttttrrrreeeeaaaammmm&&&&,,,, IIIIOOOOMMMMAAAANNNNIIIIPPPP((((TTTT))))&&&&))));;;;
  45.                ffffrrrriiiieeeennnndddd    oooossssttttrrrreeeeaaaammmm&&&& ooooppppeeeerrrraaaattttoooorrrr<<<<<<<<((((iiiioooossssttttrrrreeeeaaaammmm&&&&,,,, IIIIOOOOMMMMAAAANNNNIIIIPPPP((((TTTT))))&&&&))));;;;
  46.      }}}};;;;
  47.      ccccllllaaaassssssss IIIIOOOOAAAAPPPPPPPP((((TTTT)))) {{{{
  48.                IIIIOOOOAAAAPPPPPPPP((((TTTT))))(((( iiiioooossssttttrrrreeeeaaaammmm&&&& ((((****))))((((iiiioooossssttttrrrreeeeaaaammmm&&&&,,,,TTTT))))))));;;;
  49.                IIIIOOOOMMMMAAAANNNNIIIIPPPP((((TTTT)))) ooooppppeeeerrrraaaattttoooorrrr(((())))((((TTTT))));;;;
  50.      }}}};;;;
  51.  
  52.      IIIIOOOOMMMMAAAANNNNIIIIPPPPddddeeeeccccllllaaaarrrreeee((((iiiinnnntttt))));;;;
  53.      IIIIOOOOMMMMAAAANNNNIIIIPPPPddddeeeeccccllllaaaarrrreeee((((lllloooonnnngggg))));;;;
  54.  
  55.      SSSSMMMMAAAANNNNIIIIPPPP((((lllloooonnnngggg))))        rrrreeeesssseeeettttiiiioooossssffffllllaaaaggggssss((((lllloooonnnngggg))));;;;
  56.      SSSSMMMMAAAANNNNIIIIPPPP((((iiiinnnntttt))))         sssseeeettttffffiiiillllllll((((iiiinnnntttt))));;;;
  57.      SSSSMMMMAAAANNNNIIIIPPPP((((lllloooonnnngggg))))        sssseeeettttiiiioooossssffffllllaaaaggggssss((((lllloooonnnngggg))));;;;
  58.      SSSSMMMMAAAANNNNIIIIPPPP((((iiiinnnntttt))))         sssseeeettttpppprrrreeeecccciiiissssiiiioooonnnn((((iiiinnnntttt))));;;;
  59.      SSSSMMMMAAAANNNNIIIIPPPP((((iiiinnnntttt))))         sssseeeettttwwww((((iiiinnnntttt wwww))));;;;
  60.  
  61.  
  62.  
  63.                                                                         PPPPaaaaggggeeee 1111
  64.  
  65.  
  66.  
  67.  
  68.  
  69.  
  70. MMMMAAAANNNNIIIIPPPP((((3333CCCC++++++++))))                                                        MMMMAAAANNNNIIIIPPPP((((3333CCCC++++++++))))
  71.  
  72.  
  73.  
  74. DDDDEEEESSSSCCCCRRRRIIIIPPPPTTTTIIIIOOOONNNN
  75.      Manipulators are values that may be "inserted into" or "extracted from"
  76.      streams to achieve some effect (other than to insert or extract a value
  77.      representation), with a convenient syntax.  They enable one to embed a
  78.      function call in an expression containing a series of insertions or
  79.      extractions.  For example, the predefined manipulator for ostreams,
  80.      fffflllluuuusssshhhh, can be used as follows:
  81.                ccccoooouuuutttt <<<<<<<< fffflllluuuusssshhhh
  82.      to flush cout.  Several iostream classes supply manipulators:  see
  83.      _i_o_s(_3_C++), _i_s_t_r_e_a_m(_3_C++), and _o_s_t_r_e_a_m(_3_C++).  fffflllluuuusssshhhh is a simple
  84.      manipulator; some manipulators take arguments, such as the predefined ios
  85.      mmmmaaaannnniiiippppuuuullllaaaattttoooorrrrssss,,,, sssseeeettttffffiiiillllllll aaaannnndddd sssseeeettttwwww ((((sssseeeeeeee bbbbeeeelllloooowwww))))....  TTTThhhheeee hhhheeeeaaaaddddeeeerrrr ffffiiiilllleeee iiiioooommmmaaaannnniiiipppp....hhhh
  86.      ssssuuuupppppppplllliiiieeeessss mmmmaaaaccccrrrroooo ddddeeeeffffiiiinnnniiiittttiiiioooonnnnssss wwwwhhhhiiiicccchhhh pppprrrrooooggggrrrraaaammmmmmmmeeeerrrrssss ccccaaaannnn uuuusssseeee ttttoooo ddddeeeeffffiiiinnnneeee nnnneeeewwww
  87.      ppppaaaarrrraaaammmmeeeetttteeeerrrriiiizzzzeeeedddd mmmmaaaannnniiiippppuuuullllaaaattttoooorrrrssss....
  88.  
  89.      Ideally, the types relating to manipulators would be parameterized as
  90.      "templates."  The macros defined in iomanip.h are used to simulate
  91.      templates.  IIIIOOOOMMMMAAAANNNNIIIIPPPPddddeeeeccccllllaaaarrrreeee((((TTTT)))) declares the various classes and operators.
  92.      (All code is declared inline so that no separate definitions are
  93.      required.)  Each of the other TTTTs is used to construct the real names and
  94.      therefore must be a single identifier.  Each of the other macros also
  95.      requires an identifier and expands to a name.
  96.  
  97.      In the following descriptions, assume:
  98.      - tttt is a TTTT, or type name.
  99.      - ssss is an ios.
  100.      - iiii is an istream.
  101.      - oooo is an ostream.
  102.      - iiiioooo is an iostream.
  103.      - ffff is an ios& (*)(ios&).
  104.      - iiiiffff is an istream& (*)(istream&).
  105.      - ooooffff is an ostream& (*)(ostream&).
  106.      - iiiiooooffff is an iostream& (*)(iostream&).
  107.      - nnnn is an int....
  108.      ---- llll iiiissss aaaa lllloooonnnngggg....
  109.  
  110.           ssss<<<<<<<<SSSSMMMMAAAANNNNIIIIPPPP((((TTTT))))((((ffff,,,,tttt))))
  111.           ssss>>>>>>>>SSSSMMMMAAAANNNNIIIIPPPP((((TTTT))))((((ffff,,,,tttt))))
  112.           ssss<<<<<<<<SSSSAAAAPPPPPPPP((((TTTT))))((((ffff))))((((tttt))))
  113.           ssss>>>>>>>>SSSSAAAAPPPPPPPP((((TTTT))))((((ffff))))((((tttt))))
  114.      Returns ffff((((ssss,,,,tttt)))), where ssss is the left operand of the insertion or extractor
  115.      operator (i.e., ssss, iiii, oooo, or iiiioooo).
  116.  
  117.           iiii>>>>>>>>IIIIMMMMAAAANNNNIIIIPPPP((((TTTT))))((((iiiiffff,,,,tttt))))
  118.           iiii>>>>>>>>IIIIAAAAPPPPPPPP((((TTTT))))((((iiiiffff))))((((tttt))))
  119.      Returns iiiiffff((((iiii,,,,tttt)))).
  120.  
  121.           oooo<<<<<<<<OOOOMMMMAAAANNNNIIIIPPPP((((TTTT))))((((ooooffff,,,,tttt))))
  122.           oooo<<<<<<<<OOOOAAAAPPPPPPPP((((TTTT))))((((ooooffff))))((((tttt))))
  123.      Returns ooooffff((((oooo,,,,tttt)))).
  124.  
  125.           iiiioooo<<<<<<<<IIIIOOOOMMMMAAAANNNNIIIIPPPP((((TTTT))))((((iiiiooooffff,,,,tttt))))
  126.  
  127.  
  128.  
  129.                                                                         PPPPaaaaggggeeee 2222
  130.  
  131.  
  132.  
  133.  
  134.  
  135.  
  136. MMMMAAAANNNNIIIIPPPP((((3333CCCC++++++++))))                                                        MMMMAAAANNNNIIIIPPPP((((3333CCCC++++++++))))
  137.  
  138.  
  139.  
  140.           iiiioooo>>>>>>>>IIIIOOOOMMMMAAAANNNNIIIIPPPP((((TTTT))))((((iiiiooooffff,,,,tttt))))
  141.           iiiioooo<<<<<<<<IIIIOOOOAAAAPPPPPPPP((((TTTT))))((((iiiiooooffff))))((((tttt))))
  142.           iiiioooo>>>>>>>>IIIIOOOOAAAAPPPPPPPP((((TTTT))))((((iiiiooooffff))))((((tttt))))
  143.      Returns iiiiooooffff((((iiiioooo,,,,tttt)))).
  144.  
  145.      iomanip.h contains two declarations, IOMANIPdeclare(int) and
  146.      IOMANIPdeclare(long) and some manipulators that take an int or a long
  147.      argument.  These manipulators all have to do with changing the format
  148.      state of a stream; see _i_o_s(_3_C++) for further details.
  149.  
  150.           oooo<<<<<<<<sssseeeettttwwww((((nnnn))))
  151.           iiii>>>>>>>>sssseeeettttwwww((((nnnn))))
  152.      Sets the field width of the stream (left-hand operand: oooo or iiii) to nnnn.
  153.  
  154.           oooo<<<<<<<<sssseeeettttffffiiiillllllll((((nnnn))))
  155.           iiii>>>>>>>>sssseeeettttffffiiiillllllll((((nnnn))))
  156.      Sets the fill character of the stream (oooo or iiii, or) to be nnnn.
  157.  
  158.           oooo<<<<<<<<sssseeeettttpppprrrreeeecccciiiissssiiiioooonnnn((((nnnn))))
  159.           iiii>>>>>>>>sssseeeettttpppprrrreeeecccciiiissssiiiioooonnnn((((nnnn))))
  160.      Sets the precision of the stream (oooo or iiii) to be nnnn.
  161.  
  162.           oooo<<<<<<<<sssseeeettttiiiioooossssffffllllaaaaggggssss((((llll))))
  163.           iiii>>>>>>>>sssseeeettttiiiioooossssffffllllaaaaggggssss((((llll))))
  164.      Turns on in the stream (oooo or iiii) the format flags marked in llll.  (Calls
  165.      oooo....sssseeeettttffff((((llll)))) or iiii....sssseeeettttffff((((llll))))).
  166.  
  167.           oooo<<<<<<<<rrrreeeesssseeeettttiiiioooossssffffllllaaaaggggssss((((llll))))
  168.           iiii>>>>>>>>rrrreeeesssseeeettttiiiioooossssffffllllaaaaggggssss((((llll))))
  169.      Clears in the stream (oooo or iiii) the format bits specified by llll.  (Calls
  170.      oooo....sssseeeettttffff((((0000,,,,llll)))) or iiii....sssseeeettttffff((((0000,,,,llll))))).
  171.  
  172. CCCCAAAAVVVVEEEEAAAATTTTSSSS
  173.      Syntax errors will be reported if IIIIOOOOMMMMAAAANNNNIIIIPPPPddddeeeeccccllllaaaarrrreeee((((TTTT)))) occurs more than once
  174.      in a file with the same TTTT.
  175.  
  176. SSSSEEEEEEEE AAAALLLLSSSSOOOO
  177.      ios(3C++), istream(3C++), ostream(3C++)
  178.  
  179.  
  180.  
  181.  
  182.  
  183.  
  184.  
  185.  
  186.  
  187.  
  188.  
  189.  
  190.  
  191.  
  192.  
  193.  
  194.  
  195.                                                                         PPPPaaaaggggeeee 3333
  196.  
  197.  
  198.  
  199.